package com.itlong.cloud.operate;

import com.itlong.cloud.project.operate.IOperateAdManageServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import com.itlong.cloud.utils.date.DateUtil;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;

/**
 * <desc>
 *      运营-广告管理-定时查找过期广告。
 * <desc/>
 *
 * @createDate 2017/11/24.
 */
@EnableScheduling // 启用定时任务
@RestController
public class OperateAdPublishStatusTime {

    private static Logger LOG = LoggerFactory.getLogger(OperateAdPublishStatusTime.class);

    @Autowired
    IOperateAdManageServiceClient iOperateAdManageServiceClient;
    /**
     * <desc>
     *      定时检测过期广告并置对应状态。
     * <desc/>
     *
     * @param
     * @return
     * @author shengen.T
     * @createDate 2017/10/30
     */
    @Scheduled(cron = "0/60 * * * * ?") // 每50秒执行一次
    public void ChangePublishStatusTask() {
        try {
             iOperateAdManageServiceClient.changePublishStateTimeTask();
        } catch (Exception e) {
            throw new DataAccessException("【定时检测过期广告】检测过期广告并改变发布状态失败", e);
        }
    }
}
